//
//  HomeQuestionAndAnswerController.m
//  OnionHome
//
//  Created by fengjie on 2019/9/17.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "HomeQuestionAndAnswerController.h"
#import "HomeRecomedController.h"
#import "HomeMeAnswerController.h"
#import "AnswerDetailController.h"
#import "AnswerDetailTwoController.h"
#import "AnswerInvitedRecomendLocalVC.h"

#import "HomeQuestionAnswerModel.h"

@interface HomeQuestionAndAnswerController ()<UITableViewDelegate,UITableViewDataSource>
/**listView*/
@property (nonatomic,strong)UITableView*listView;
/**<#属性#>*/
@property (nonatomic,strong)HomeQuestionOneHeaderView*oneHeader;
/**<#属性#>*/
@property (nonatomic,strong)NSMutableArray*dataArray;
@end

@implementation HomeQuestionAndAnswerController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.listView];
    [self.listView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    [self setNotificationCenter];
}
-(void)setNotificationCenter{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadLocaData) name:K_ReleaseQuestions object:nil];
}
-(void)reloadLocaData{
    self.dataArray = nil;
    [self.listView reloadData];
}
/**
 进入答题详情
 */
-(void)pushAnswerDetail{
    [self.navigationController pushViewController:[AnswerDetailController new] animated:YES];
}
#pragma mark --UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.dataArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSArray * array = self.dataArray[section];
    return array.count;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * view = UIView.new;
    view.backgroundColor = KWhiteColor;
    NSArray * array = self.dataArray[section];
    HomeQuestionAnswerModel * model = array.lastObject;

    if (section == 0) {
        self.oneHeader.iconView.iconImage.image = model.userImage;
        [view addSubview:self.oneHeader];
        
        [self.oneHeader mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.right.bottom.mas_equalTo(0);
        }];
    }else{
        UserIconAndNameView * twoHeader = [[UserIconAndNameView alloc] initWithFrame:CGRectZero];
        twoHeader.iconImage.image = model.userImage;
        twoHeader.deleButton.hidden = YES;
        
        [view addSubview:twoHeader];
        [twoHeader mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(0);
        }];
        
        UILabel * titleLabl = UILabel.new;
        titleLabl.text = @"回答了问题";
        titleLabl.font = SYSTEMFONT(14);
        titleLabl.textColor = UIColorFromRGB(0x454F44);
        
        [twoHeader addSubview:titleLabl];
        [titleLabl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(twoHeader.userName.mas_right).offset(5);
            make.centerY.mas_equalTo(twoHeader.userName);
        }];
    }
    return view;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return UIView.new;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01f;
}
//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
//    return 0.01;
//}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    RecomedLeftTextRightImageCell * imageCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([RecomedLeftTextRightImageCell class])];
    MoreImageAndTextCell * moreCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MoreImageAndTextCell class])];
    MoreDoubleImageAndTextCell * doubleCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MoreDoubleImageAndTextCell class])];

    
    NSArray * array = self.dataArray[indexPath.section];
    
    HomeQuestionAnswerModel * model = array[indexPath.row];
    
    if (model.imagesArray.count <= 3 && model.imagesArray.count >1) {
        moreCell.qamodel = model;
        return moreCell;
    }
    if (model.imagesArray.count > 3 && model.imagesArray.count <= 6 ) {
        doubleCell.qamodel = model;
        return doubleCell;
    }

    imageCell.qamodel = model;
    return imageCell;
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        [self pushAnswerDetail];
    }else{
        [self.navigationController pushViewController:[AnswerDetailTwoController new] animated:YES];
    }
}
#pragma mark ---懒加载
-(UITableView*)listView{
    if(!_listView){
        _listView=[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _listView.delegate = self;
        _listView.dataSource = self;
//        _listView.tableFooterView = UIView.new;
//        _listView.tableHeaderView = UIView.new;
        _listView.rowHeight = UITableViewAutomaticDimension;
        _listView.estimatedRowHeight = 44.0f;
        _listView.sectionHeaderHeight = UITableViewAutomaticDimension;
        _listView.estimatedSectionHeaderHeight = 44.0f;
        _listView.sectionFooterHeight= UITableViewAutomaticDimension;
        _listView.estimatedSectionFooterHeight = 44.0f;


        _listView.backgroundColor = UIColorFromRGB(0xE9EEE7);
        [_listView setSeparatorInset:UIEdgeInsetsMake(0,0, 0, 0)];
        [_listView setSeparatorColor:UIColorFromRGB(0xE7EEE7)];
        [_listView registerClass:[RecomedLeftTextRightImageCell class] forCellReuseIdentifier:NSStringFromClass([RecomedLeftTextRightImageCell class])];
        [_listView registerClass:[MoreImageAndTextCell class] forCellReuseIdentifier:NSStringFromClass([MoreImageAndTextCell class])];
        [_listView registerClass:[MoreDoubleImageAndTextCell class] forCellReuseIdentifier:NSStringFromClass([MoreDoubleImageAndTextCell class])];
        if (@available(iOS 11.0, *)) {
            _listView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
         }else {
             self.automaticallyAdjustsScrollViewInsets = NO;
        }
        _listView.separatorColor = SeparatorColor;

    }
    return _listView;
}

-(NSMutableArray *)dataArray{
    if (!_dataArray) {
        _dataArray = [NSMutableArray array];
                
        
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"HomeQuestionAnswer" ofType:@"plist"];
           //当数据结构为数组时
        NSArray *array = [[NSArray alloc] initWithContentsOfFile:plistPath];
        
        for (NSDictionary * dic in array) {
            NSArray * itemArray = dic[@"itemArray"];
            NSMutableArray * subArray = [NSMutableArray array];
            for (NSDictionary * dic_sub in itemArray) {
                HomeQuestionAnswerModel * model = [HomeQuestionAnswerModel new];
                model.userImage = [Utilis getRandomUserImage];
                [model setValuesForKeysWithDictionary:dic_sub];
                
                if (model.imageNumber.integerValue > 0) {
                    NSMutableArray * imageArray = [NSMutableArray array];
                    for (NSInteger i = 0 ; i < model.imageNumber.integerValue; i++) {
                        [imageArray addObject:IMAGE_NAMED([Utilis getRandomDynamicImage])];
                    }
                    
                    model.imagesArray = imageArray;
                }

                [subArray addObject:model];
            }
            
            [_dataArray addObject:subArray];
        }
        if ([self getlocadata].count > 0) {
            [_dataArray insertObject:[self getlocadata] atIndex:1];
        }
    }
    return _dataArray;
}
-(NSMutableArray *)getlocadata{
    
    NSMutableArray  * arr = [NSMutableArray array];
    
    NSMutableArray * oneArray = [PlistTool getPlistType:ReleseQanswer];
    
    [oneArray enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        HomeQuestionAnswerModel *model = [HomeQuestionAnswerModel new];
        [model setValuesForKeysWithDictionary:obj];
        [arr addObject:model];
    }];
    
    return arr;
}
-(HomeQuestionOneHeaderView*)oneHeader{
    if(!_oneHeader){
        _oneHeader=[[HomeQuestionOneHeaderView alloc] initWithFrame:CGRectZero];
        _oneHeader.userInteractionEnabled = YES;
        [_oneHeader addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pushAnswerDetail)]];
    }
    return _oneHeader;
}
@end

@interface MoreImageAndTextCell ()
/**动态文字*/
@property (nonatomic,strong)UILabel*dynamicLabel;
/**人数*/
@property (nonatomic,strong)UILabel*numberLabel;
/**<#属性#>*/
@property (nonatomic,strong)UIView*imageBgView;
@end

@implementation MoreImageAndTextCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = KWhiteColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
-(void)setHomeCityModel:(HomeCityModel *)homeCityModel{
    _homeCityModel = homeCityModel;
    
//    self.dynamicLabel.text = homeCityModel.title;
    [TitleTool setDynamicTitle:homeCityModel.title Label:self.dynamicLabel];
    self.imageBgView =  [self createImagesView:homeCityModel.imageArray];
    [self addSubview:self.imageBgView];

    [self updateMasonry];

}
-(void)setQamodel:(HomeQuestionAnswerModel *)qamodel{
    _qamodel = qamodel;
//    self.dynamicLabel.text = qamodel.title;
    [TitleTool setDynamicTitle:qamodel.title Label:self.dynamicLabel];
    self.imageBgView =  [self createImagesView:qamodel.imagesArray];
    [self addSubview:self.imageBgView];

    [self updateMasonry];

}
-(void)setIndusModel:(HomeIndustryDetailsModel *)indusModel{
    _indusModel = indusModel;
//    self.dynamicLabel.text = indusModel.title;
    [TitleTool setDynamicTitle:indusModel.title Label:self.dynamicLabel];

    self.imageBgView =  [self createImagesView:indusModel.imageArray];
    [self addSubview:self.imageBgView];
    
    [self updateMasonry];

}
-(void)updateMasonry{
    
    [self.imageBgView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.dynamicLabel.mas_bottom).offset(8);
        make.right.mas_equalTo(-16);
    }];
    [self.numberLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.imageBgView.mas_bottom).offset(8);
        make.right.mas_equalTo(-30);
        make.bottom.mas_equalTo(-16);

    }];
}
-(void)createUI{
    
    self.imageBgView = UIView.new;
    
    [self addSubview:self.dynamicLabel];
    [self addSubview:self.imageBgView];
    
    UIButton * deleButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [deleButton setBackgroundImage:IMAGE_NAMED(@"icon_quxiao") forState:UIControlStateNormal];
    
    kWeakSelf(weakSelf);
    [deleButton addActionHandler:^{
        PresentationObject * object = [PresentationObject sharedPresentationObject];
        CGFloat y = (KScreenHeight - 290)/2;
//            object.alpha_bgView = 0.3;
        object.subViewFrame =CGRectMake(20, y, KScreenWidth-40, 290);
        OneToastController * vc = [OneToastController new];
        [object showPresentingViewController:[weakSelf getCurrentViewController] PresentedViewController:[[BasseNavigationController alloc]initWithRootViewController:vc]];
        vc.notInterestedBlock = ^{
            
        };
    }];

    
    [self addSubview:self.numberLabel];
    [self addSubview:deleButton];

    
    [self.dynamicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.mas_equalTo(16);
    }];
    [self.imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.dynamicLabel.mas_bottom).offset(8);
        make.right.mas_equalTo(-16);
    }];
    
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.imageBgView.mas_bottom).offset(8);
        make.right.mas_equalTo(-30);
        make.bottom.mas_equalTo(-16);

    }];

    [deleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.mas_equalTo(self.numberLabel);
    }];

}

-(UILabel*)dynamicLabel{
    if(!_dynamicLabel){
        _dynamicLabel=[UILabel new];
        _dynamicLabel.font = SYSTEMFONT(18);
        _dynamicLabel.textColor = UIColorFromRGB(0x273323);
        _dynamicLabel.numberOfLines = 2;
        _dynamicLabel.text = @"过夜的韭菜能不能吃？什么情况下会产生亚硝酸盐，危害人体健康？";
        
    }
    return _dynamicLabel;
}
-(UIView *)createImagesView:(NSMutableArray *)array{
    if (array == nil) {
        array = [NSMutableArray array];
        [array addObject:IMAGE_NAMED([Utilis getRandomDynamicImage])];
        [array addObject:IMAGE_NAMED([Utilis getRandomDynamicImage])];
        [array addObject:IMAGE_NAMED([Utilis getRandomDynamicImage])];

    }
    UIView * view = UIView.new;
    CGFloat width = (KScreenWidth - 32 - 8)/3;
    CGFloat spacing = 4;
    
    for (NSInteger i = 0; i < array.count; i++) {
        UIImageView * imageView = UIImageView.new;
        imageView.image = IMAGE_NAMED(@"dynamicDefut");
        
        imageView.image = array[i];

        [view addSubview:imageView];
        
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(width * i + spacing * i);
            make.top.bottom.mas_equalTo(0);
            make.width.mas_equalTo(width);
            make.height.mas_equalTo(84);
            
        }];
        
    }
    
    
    return view;
}
-(UILabel*)numberLabel{
    if(!_numberLabel){
        _numberLabel=[UILabel new];
        _numberLabel.textColor = UIColorFromRGB(0x959E97);
        _numberLabel.font = SYSTEMFONT(12);
        _numberLabel.text = @"葱花之家 312评论 30分钟前";
    }
    return _numberLabel;
}

@end


@interface MoreDoubleImageAndTextCell ()

/**动态文字*/
@property (nonatomic,strong)UILabel*dynamicLabel;
/**人数*/
@property (nonatomic,strong)UILabel*numberLabel;
/**<#属性#>*/
@property (nonatomic,strong)UIView*imageBgView;
@end


@implementation MoreDoubleImageAndTextCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = KWhiteColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
-(void)setHomeCityModel:(HomeCityModel *)homeCityModel{
    _homeCityModel = homeCityModel;
    
    self.dynamicLabel.text = homeCityModel.title;
    self.imageBgView =  [self createImagesView:homeCityModel.imageArray];
    [self addSubview:self.imageBgView];

    [self updateMasonry];

}
-(void)setQamodel:(HomeQuestionAnswerModel *)qamodel{
    _qamodel = qamodel;
//    self.dynamicLabel.text = qamodel.title;
    [TitleTool setDynamicTitle:qamodel.title Label:self.dynamicLabel];
    self.imageBgView =  [self createImagesView:qamodel.imagesArray];
    [self addSubview:self.imageBgView];

    [self updateMasonry];

}
-(void)setIndusModel:(HomeIndustryDetailsModel *)indusModel{
    _indusModel = indusModel;
//    self.dynamicLabel.text = indusModel.title;
    [TitleTool setDynamicTitle:indusModel.title Label:self.dynamicLabel];

    self.imageBgView =  [self createImagesView:indusModel.imageArray];
    [self addSubview:self.imageBgView];
    
    [self updateMasonry];

}
-(void)updateMasonry{
    
    [self.imageBgView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.dynamicLabel.mas_bottom).offset(8);
        make.right.mas_equalTo(-16);
    }];
    [self.numberLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.imageBgView.mas_bottom).offset(8);
        make.right.mas_equalTo(-30);
        make.bottom.mas_equalTo(-16);

    }];
}
-(void)createUI{
    
    self.imageBgView = UIView.new;
    
    [self addSubview:self.dynamicLabel];
    [self addSubview:self.imageBgView];
    
    UIButton * deleButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [deleButton setBackgroundImage:IMAGE_NAMED(@"icon_quxiao") forState:UIControlStateNormal];
    
    [self addSubview:self.numberLabel];
    [self addSubview:deleButton];

    
    [self.dynamicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.mas_equalTo(16);
    }];
    [self.imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.dynamicLabel.mas_bottom).offset(8);
        make.right.mas_equalTo(-16);
    }];
    
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.imageBgView.mas_bottom).offset(8);
        make.right.mas_equalTo(-30);
        make.bottom.mas_equalTo(-16);

    }];

    [deleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.mas_equalTo(self.numberLabel);
    }];

}

-(UILabel*)dynamicLabel{
    if(!_dynamicLabel){
        _dynamicLabel=[UILabel new];
        _dynamicLabel.font = SYSTEMFONT(18);
        _dynamicLabel.textColor = UIColorFromRGB(0x273323);
        _dynamicLabel.numberOfLines = 2;
        _dynamicLabel.text = @"过夜的韭菜能不能吃？什么情况下会产生亚硝酸盐，危害人体健康？";
        
    }
    return _dynamicLabel;
}
-(UIView *)createImagesView:(NSMutableArray *)array{
    if (array == nil) {
        array = [NSMutableArray array];
        [array addObject:IMAGE_NAMED([Utilis getRandomDynamicImage])];
        [array addObject:IMAGE_NAMED([Utilis getRandomDynamicImage])];
        [array addObject:IMAGE_NAMED([Utilis getRandomDynamicImage])];
        [array addObject:IMAGE_NAMED([Utilis getRandomDynamicImage])];

    }
    UIView * view = UIView.new;
    CGFloat width = (KScreenWidth - 32 - 8)/3;
    CGFloat spacing = 4;
    
    CGFloat left = 0;
    CGFloat top = 0;
    CGFloat height = 84;
    
    for (NSInteger i = 0; i < array.count; i++) {
        UIImageView * imageView = UIImageView.new;
        imageView.image = IMAGE_NAMED(@"dynamicDefut");
        imageView.image = array[i];
        [view addSubview:imageView];
        
        if (i < 3) {
            left = width * i + spacing * i;
            top = 0;
        }
        if (i >= 3 && i < 6) {
            left = width * (i - 3) + spacing * (i - 3);
            top = height;
        }
        
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(left);
            make.top.mas_equalTo(top);
            make.width.mas_equalTo(width);
            make.height.mas_equalTo(height);
            if (i > 3 && i <= 6) {
                make.bottom.mas_equalTo(0);
            }
        }];
        
    }
    
    
    return view;
}
-(UILabel*)numberLabel{
    if(!_numberLabel){
        _numberLabel=[UILabel new];
        _numberLabel.textColor = UIColorFromRGB(0x959E97);
        _numberLabel.font = SYSTEMFONT(12);
        _numberLabel.text = @"葱花之家 312评论 30分钟前";
    }
    return _numberLabel;
}


@end






#import "AskQuestionsController.h"

@interface HomeQuestionOneHeaderView ()


@end

@implementation HomeQuestionOneHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}
-(void)createUI{
    
    UIButton * oneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [oneBtn setTitle:@"答题" forState:UIControlStateNormal];
    [oneBtn setTitleColor:UIColorFromRGB(0x273323) forState:UIControlStateNormal];
    [oneBtn setImage:IMAGE_NAMED(@"答题") forState:UIControlStateNormal];
    oneBtn.titleLabel.font = SYSTEMFONT(14);
    [oneBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, -4)];
    
    kWeakSelf(weakSelf);
    [oneBtn addActionHandler:^{
        AskQuestionsController * askVC = [AskQuestionsController new];
        askVC.type = AskQuestionsAnswer;
        [[weakSelf getCurrentViewController].navigationController pushViewController:askVC animated:YES];
    }];

    
    UIButton * twoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [twoBtn setTitle:@"提问" forState:UIControlStateNormal];
    [twoBtn setImage:IMAGE_NAMED(@"首页_提问") forState:UIControlStateNormal];
    [twoBtn setTitleColor:UIColorFromRGB(0x273323) forState:UIControlStateNormal];
    twoBtn.titleLabel.font = SYSTEMFONT(14);
    [twoBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, -4)];

    [twoBtn addActionHandler:^{
        [[weakSelf getCurrentViewController].navigationController pushViewController:[AnswerInvitedRecomendLocalVC new] animated:YES];
    }];
    
    self.iconView = [[UserIconAndNameView alloc] initWithFrame:CGRectZero];
    self.iconView.deleButton.hidden = YES;
    
    UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setTitle:@"我的问答" forState:UIControlStateNormal];
    [rightBtn setTitleColor:UIColorFromRGB(0x959E97) forState:UIControlStateNormal];
    rightBtn.titleLabel.font = SYSTEMFONT(12);
    ViewBorderRadius(rightBtn, 4, 1, UIColorFromRGB(0x959E97));
    
    [rightBtn addActionHandler:^{
        [[weakSelf getCurrentViewController].navigationController pushViewController:[HomeMeAnswerController new] animated:YES];
    }];
    
    UIView * oneline = UIView.new;
    oneline.backgroundColor = UIColorFromRGB(0xF5F7F5);
    
    
    [self addSubview:self.iconView];
    [self.iconView addSubview:rightBtn];
    
    [self addSubview:oneBtn];
    [self addSubview:twoBtn];
    
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
    }];
    
    [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-16);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(27);
    }];

    [oneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(68);
        make.top.mas_equalTo(self.iconView.mas_bottom).offset(16);
        make.bottom.mas_equalTo(-16);
    }];
    [twoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-68);
        make.top.mas_equalTo(self.iconView.mas_bottom).offset(16);
        make.bottom.mas_equalTo(-16);
    }];

}
@end
